<?php
namespace app\admin\model;

use think\Model;

class MarketSmCopywriting extends BaseModel
{
    protected $attributes = [
        'platform' => [
            1 => 'facebook',
            2 => 'twitter',
            3 => 'ins',
            4 => 'vk',
            5 => 'tiktok'
        ],
        'status' => [
            0 => '未使用',
            1 => '已使用'
        ]
    ];

    public function getAttributes()
    {
        return $this->attributes;
    }

    public function getPlatformValueAttr($value, $data)
    {
        return isset($this->attributes['platform'][$data['platform']]) ? $this->attributes['platform'][$data['platform']] : '';
    }

    public function task()
    {
//        $bind = ['channel_id','language_id','account_group_id','mining_machine_task' => 'mining_machine','cue_word'];
        return $this->belongsTo(MarketSmCopywritingTasks::class, 'sm_generate_opywriting_tasks_id', 'id');
    }

    public function account()
    {
        return $this->belongsTo(MarketSocialMediaAccount::class, 'social_media_account_id', 'id')->bind(['account_name' => 'account', 'windows_id']);
    }

    public function cryptoNews()
    {
        return $this->hasOne(CryptoNews::class, 'id', 'crypto_news_id');
    }

    public function marketNewsSearchDet()
    {
        return $this->hasMany(MarketNewsSearchDet::class, 'crypto_news_id', 'crypto_news_id');
    }
}

?>
